package com.youbug.mall.cart.feign.impl;

import com.youbug.common.constant.CartConstant;
import com.youbug.mall.cart.service.CartService;
import com.youbug.mall.cart.vo.CartItemVo;
import com.youbug.mall.order_oms.feign.IOrderCartFeignService;
import com.youbug.mall.order_oms.vo.OrderItemVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class OrderCartFeignServiceImpl implements IOrderCartFeignService {
     @Autowired
     private CartService cartService;

     @Autowired
     private StringRedisTemplate redisTemplate;

    @Override
    public List<OrderItemVo> getCurrentUserCartItems() {

        List<CartItemVo> cartItemVos = cartService.getCurrentUserCartItems();

        List<OrderItemVo> collect = cartItemVos.stream().map(e -> {
            OrderItemVo itemVo = new OrderItemVo();
            BeanUtils.copyProperties(e, itemVo);
            return itemVo;
        }).collect(Collectors.toList());

        return collect;
    }

}
